package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.SoulQuestionContent;
import com.tanhua.dubbo.api.SoulQuestionContentApi;
import com.tanhua.dubbo.mapper.SoulQuestionContentMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class SoulQuestionContentApiImpl implements SoulQuestionContentApi {
    @Autowired
    private SoulQuestionContentMapper soulQuestionContentMapper;
    
    
    /**
     * 添加
     *
     * @param soulQuestionContent
     */
    @Override
    public void save(SoulQuestionContent soulQuestionContent) {
        soulQuestionContentMapper.insert(soulQuestionContent);
    }
    
    /**
     * 查询所有的对应等级的问题
     *
     * @param level
     */
    @Override
    public List<SoulQuestionContent> findByLevel(String level) {
        QueryWrapper<SoulQuestionContent> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("level", level);
        return soulQuestionContentMapper.selectList(queryWrapper);
    }
    
    /**
     * 根据问题的id查询该问题属于的等级
     */
    @Override
    public String findQuestionLevel(Long questionId) {
        QueryWrapper<SoulQuestionContent> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", questionId);
        return soulQuestionContentMapper.selectOne(queryWrapper).getLevel();
        
    }
}
